home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / SessionRequest.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  4.1 KB  |  115 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.EOFException;
  6. import java.io.IOException;
  7. import java.util.Vector;
  8. import symjava.sql.SQLException;
  9.  
  10. class SessionRequest extends Requester {
  11.    int _id;
  12.    // $FF: renamed from: _v java.util.Vector
  13.    Vector field_0;
  14.    int _mode;
  15.    NetString _reqStr;
  16.  
  17.    SessionRequest(ClientSession sess) {
  18.       super(sess);
  19.    }
  20.  
  21.    protected IO getIO() throws NetException, SQLException {
  22.       return this._mode == 1 ? super._io : super.getIO();
  23.    }
  24.  
  25.    protected void releaseIO() {
  26.       if (this._mode != 1) {
  27.          super.releaseIO();
  28.       }
  29.    }
  30.  
  31.    int connect() throws NetException {
  32.       this._mode = 0;
  33.       this._id = 0;
  34.       this._reqStr = new NetString("session" + super._reqDelim + "connect" + super._reqDelim + 1 + super._reqDelim + 0);
  35.  
  36.       try {
  37.          ((Requester)this).execute();
  38.          return this._id;
  39.       } catch (SQLException e) {
  40.          throw new NetException(((Throwable)e).getMessage());
  41.       } catch (Exception var3) {
  42.          throw new NetException("Unable to connect to server.");
  43.       }
  44.    }
  45.  
  46.    void reconnect(IO io, int connectionID) throws NetException {
  47.       this._mode = 1;
  48.       super._io = io;
  49.       this._reqStr = new NetString("session" + super._reqDelim + "reconnect" + super._reqDelim + connectionID);
  50.  
  51.       try {
  52.          ((Requester)this).execute();
  53.       } catch (Exception var3) {
  54.          throw new NetException("Error reconnecting IO object.");
  55.       }
  56.    }
  57.  
  58.    void loginPublic(String userName, String password) throws SQLException {
  59.       this._mode = 2;
  60.       this._reqStr = new NetString("session" + super._reqDelim + "loginpublic" + super._reqDelim + userName + super._reqDelim + password);
  61.       ((Requester)this).execute();
  62.    }
  63.  
  64.    void loginPrivate(String key, String userName, String password) throws SQLException {
  65.       this._mode = 3;
  66.       this._reqStr = new NetString("session" + super._reqDelim + "loginprivate" + super._reqDelim + key + super._reqDelim + userName + super._reqDelim + password);
  67.       ((Requester)this).execute();
  68.    }
  69.  
  70.    Vector getRepositoryList() throws SQLException {
  71.       this._mode = 4;
  72.       this.field_0 = null;
  73.       this._reqStr = new NetString("session" + super._reqDelim + "getRepList");
  74.       ((Requester)this).execute();
  75.       if (this.field_0 == null) {
  76.          throw new SQLException("Error getting repository list.");
  77.       } else {
  78.          return this.field_0;
  79.       }
  80.    }
  81.  
  82.    void disconnect() {
  83.       this._mode = 5;
  84.       this._reqStr = new NetString("session" + super._reqDelim + "disconnect");
  85.  
  86.       try {
  87.          ((Requester)this).execute();
  88.       } catch (Exception var1) {
  89.       }
  90.    }
  91.  
  92.    protected void readResults(DataInputStream in) throws SQLException, IOException, ErrorException {
  93.       if (this._mode != 5) {
  94.          ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  95.          if ((this._mode == 0 || this._mode == 1 || this._mode == 2 || this._mode == 3) && obj.getType() == 51) {
  96.             if (this._mode == 0) {
  97.                try {
  98.                   this._id = ((NetData)obj).getInt();
  99.                } catch (EOFException var3) {
  100.                   throw new IOException();
  101.                }
  102.             }
  103.          } else if (this._mode == 4 && obj.getType() == 54) {
  104.             this.field_0 = ((ServerList)obj).toStringVector();
  105.          } else {
  106.             ((Requester)this).onObjectError(obj);
  107.          }
  108.       }
  109.    }
  110.  
  111.    protected void writeRequest(DataOutputStream out) throws IOException {
  112.       this._reqStr.write(out);
  113.    }
  114. }
  115.